package cn.usian.controller;

import cn.usian.pojo.Emp;
import cn.usian.service.EmpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@CrossOrigin
@RestController
@RequestMapping("/emp")
public class EmpController {
    @Autowired
    private EmpService empService;
    @RequestMapping("findAll")
    public List<Emp> findAll(){
        return empService.findAll();
    }
    @RequestMapping("/add")
    public void add(@RequestBody Emp emp){
        empService.add(emp);
    }
    @RequestMapping("del")
    public void del(int id){
        empService.del(id);
    }
    @RequestMapping("findByid")
    public Emp findByid(int id){
        return empService.findByid(id);
    }
    @RequestMapping("/update")
    public void update(@RequestBody Emp emp){
        empService.update(emp);
    }
}
